<template>
	<view>
		<view class="nav-bar-box">
			<view class="left-box" v-if="showLeftIcon" @click="clickLeft">
				<uni-icons type="back" size="24" color="#fff"></uni-icons>
			</view>
			<view :style="[{ textAlign: showLeftIcon ? 'center' : 'left' }, { fontSize: titleFontSize + 'rpx' }]"
				class="title" @click="titleClick">{{ title }}
				<view style="margin-left: 10rpx;transform: translateY(-3rpx);" v-if="needBottom"><uni-icons
						type="bottom" size="10"></uni-icons></view>
			</view>
			<view class="right-box"  @click="clickRight">
				<slot name="rightPart" v-if="rightSlot"></slot>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'NavBar',
		props: {
			title: {
				type: String,
				default: ''
			},
			showLeftIcon: {
				type: Boolean,
				default: true
			},
			leftSlot: {
				type: Boolean,
				default: false
			},
			rightSlot: {
				type: Boolean,
				default: false
			},
			titleFontSize: {
				type: [String, Number],
				default: 38
			},
			needBottom: {
				type: Boolean,
				default: false
			},
			backUrl: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
			}
		},
		created() {
		},
		methods: {
			clickLeft() {
				if (this.backUrl) {
					uni.switchTab({ url: this.backUrl })
				} else {
					uni.navigateBack()
				}
			},
			titleClick() {
				this.$emit('titleClick')
			},
			clickRight() {}
		}
	}
</script>
<style lang="scss" scoped>
	.nav-bar-box {
		display: flex;
		align-items: flex-end;
		position: relative;
		padding: 0 30rpx 20rpx;
		height: 90px;
		background: #c27e15;

		.left-box {
			position: absolute;
			left: 0;
			display: flex;
			align-items: center;
		}

		.title {
			display: flex;
			justify-content: center;
			flex: 1;
			width: 0;
			padding: 0 32rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #fff;
		}
		.right-box {
			position: absolute;
			right: 30rpx;
			display: flex;
			align-items: center;
		}
	}
</style>